package com.feng;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;

/**
 * Hello world!
 *
 */
@SpringBootApplication
public class GateWayApplication
{
    @Value("${test.uri}")
    private String uri;

    //使用RouteLocator的Bean进行路由转发，将请求进行处理，最后转发到目标的下游服务
    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder builder){
        return builder.routes().route(r -> r.path("/order/**").uri(uri)).build();
    }

    public static void main(String[] args) {
        SpringApplication.run(GateWayApplication.class, args);

    }
}
